*******************************************************************************
** REPLICATION FILES                                                         **
** The Effects of Disctrict Magnitude on Voting Behaviour                    **
** August 2016                                                               **
*******************************************************************************

cd "C:\Users\hortalav\Dropbox\Research\_Submitted\DistrictSize\Hix-Hortala-Vallve (1)\Latex File\Latex File JOP\Data_and_ReplicationMaterial"
use "Data_DistrictMagnitudeAugust2016.dta", clear


// TABLE 1
list M period VOTE_1 VOTE_2 VOTE_3 VOTE_4 VOTE_5 CAND_1 CAND_2 CAND_3 CAND_4 CAND_5 if period>=11 & period<=15 & subject==1 & session==3
list M period VOTE_1 VOTE_2 VOTE_3 VOTE_4 VOTE_5 CAND_1 CAND_2 CAND_3 CAND_4 CAND_5 if period>=11 & period<=15 & subject==1 & session==2
list M period VOTE_1 VOTE_2 VOTE_3 VOTE_4 VOTE_5 CAND_1 CAND_2 CAND_3 CAND_4 CAND_5 if period>=11 & period<=15 & subject==1 & session==4
list M period VOTE_1 VOTE_2 VOTE_3 VOTE_4 VOTE_5                                    if period>=11 & period<=15 & subject==1 & session==5

// TABLE 2
replace M=99 if M==0 	      	// rename PR treatments so that it appears last
gen vote_BOTH = (vote_EXP==1 & vote_STRAT==1)
// generate variable that is equal one when strategic & sincere vote coincide:
quietly{
egen max_eu =   rmax (Eu_1 Eu_2 Eu_3 Eu_4 Eu_5)
egen max_pref = rmax (pref_1 pref_2 pref_3 pref_4 pref_5)
gen     predicted_BOTH =      (Eu_1 == max_eu & pref_1==max_pref)
replace predicted_BOTH = 1 if (Eu_2 == max_eu & pref_2==max_pref)
replace predicted_BOTH = 1 if (Eu_3 == max_eu & pref_3==max_pref)
replace predicted_BOTH = 1 if (Eu_4 == max_eu & pref_4==max_pref)
replace predicted_BOTH = 1 if (Eu_5 == max_eu & pref_5==max_pref)
}
sort M
by M: sum vote_EXP vote_STRAT vote_BOTH predicted_BOTH

// TABLE 3
egen max_vote = rmax (L_VOTE_1 L_VOTE_2 L_VOTE_3 L_VOTE_4 L_VOTE_5)
gen     predicted_DISJOINT = 1 - predicted_BOTH
replace predicted_DISJOINT = 0 if (Eu_1 == max_eu & L_VOTE_1==max_vote)
replace predicted_DISJOINT = 0 if (Eu_2 == max_eu & L_VOTE_2==max_vote)
replace predicted_DISJOINT = 0 if (Eu_3 == max_eu & L_VOTE_3==max_vote)
replace predicted_DISJOINT = 0 if (Eu_4 == max_eu & L_VOTE_4==max_vote)
replace predicted_DISJOINT = 0 if (Eu_5 == max_eu & L_VOTE_5==max_vote)
replace predicted_DISJOINT = 0 if (pref_1==max_pref & L_VOTE_1==max_vote)
replace predicted_DISJOINT = 0 if (pref_2==max_pref & L_VOTE_2==max_vote)
replace predicted_DISJOINT = 0 if (pref_3==max_pref & L_VOTE_3==max_vote)
replace predicted_DISJOINT = 0 if (pref_4==max_pref & L_VOTE_4==max_vote)
replace predicted_DISJOINT = 0 if (pref_5==max_pref & L_VOTE_5==max_vote)
gen vote_OTHER = (vote_EXP==0 & vote_STRAT==0 & vote_FRONT==0)

sort M
by M: sum vote_EXP vote_STRAT vote_FRONT vote_OTHER if predicted_DISJOINT==1
